home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / falcon / programm.ing / falclib4.lzh / ROUTS / FADE2.S < prev    next >
Text File  |  1994-09-29  |  3KB  |  109 lines

  1. *This routine is from:
  2.  
  3. * THE JAGUAR DEMO!
  4. ; Code by Genie and EGB's Smelly Sox!
  5. ; Music by Metronome of Adrenalin!
  6. ; Mod replay by Bitmaster of BSW!
  7. ; This code is (c) 1994 PB Productions!
  8. ; Uses Devpac for the odd bit of 68030 code, uses tabs = 8
  9.  
  10.  
  11. * Fadeit - true colour versh, coded by <Genie!> of Network Trash.
  12. *
  13. ; This one uses two pixels at once
  14. ;
  15. ; a0 = pointer to colour to change
  16. ; a1 = pointer to target colour
  17. *(destroys d1-d4; adds 4 to a0-a1)
  18.  
  19. *
  20. * Code optimized by Johan Karlsson
  21. *
  22.  
  23.  
  24. @fadetrupix2
  25. .red
  26.     move.l    (a1)+,d1        Get target pixel
  27.     move.l    (a0),d2            Get pixel to change
  28.     cmp.l    d1,d2            Is pixel colours the same?
  29.     beq    .bye             If so, don't bother- we've finished!
  30.  
  31.     move    d1,d3            {
  32.     move    d2,d4            { --- Isolate R bits
  33.     andi    #%1111100000000000,d3    {
  34.     andi    #%1111100000000000,d4    {
  35.     cmp    d3,d4            Are the R bits the same?
  36.     beq.s    .rok             If so, try the G bits.
  37.     bhi.s    .rsub             If the target pixel has smaller amount of red-|
  38. .radd    addi    #%0000100000000000,d2    Otherwise add an element of red.           |
  39.     bra.s    .rok                                       |
  40. .rsub    subi    #%0000100000000000,d2     ... take away an element of red. <------------|
  41. .rok
  42. .green    move    d1,d3            {
  43.     move    d2,d4            { --- Isolate G bits
  44.     andi    #%11111000000,d3    {
  45.     andi    #%11111000000,d4    {
  46.     cmp    d3,d4            Are the G bits the same?
  47.     beq.s    .gok             If so, try the B bits.
  48.     bhi.s    .gsub             If the target has smaller amount of green-----|
  49. .gadd    add    #%00001000000,d2     Otherwise add an element of green.           |
  50.     bra.s    .gok                                       |
  51. .gsub    subi    #%00001000000,d2     ... take away an element of green. <----------|
  52. .gok
  53. .blue    move    d1,d3            {
  54.     move    d2,d4            { --- Isolate B bits
  55.     andi    #%11111,d3        {
  56.     andi    #%11111,d4        {
  57.     cmp    d3,d4            Are the B bits the same?
  58.     beq.s    .bok             If so, finish.
  59.     bhi.s    .bsub             If the target has smaller amounts of blue-----|
  60. .badd    addq.l    #1,d2             Otherwise add an element of blue.           |
  61.     bra.s    .bok                                       |
  62. .bsub    subq.l    #1,d2             ... take away an element of blue. <-----------|
  63. .bok    
  64.  
  65.     swap    d1
  66.     swap    d2
  67.  
  68. .red2
  69.     move    d1,d3            {
  70.     move    d2,d4            { --- Isolate R bits
  71.     andi    #%1111100000000000,d3    {
  72.     andi    #%1111100000000000,d4    {
  73.     cmp    d3,d4            Are the R bits the same?
  74.     beq.s    .rok2             If so, try the G bits.
  75.     bhi.s    .rsub2             If the target pixel has smaller amount of red-|
  76. .radd2    addi    #%0000100000000000,d2    Otherwise add an element of red.           |
  77.     bra.s    .rok2                                       |
  78. .rsub2    subi    #%0000100000000000,d2     ... take away an element of red. <------------|
  79. .rok2
  80. .green2    move    d1,d3            {
  81.     move    d2,d4            { --- Isolate G bits
  82.     andi    #%11111000000,d3    {
  83.     andi    #%11111000000,d4    {
  84.     cmp    d3,d4            Are the G bits the same?
  85.     beq.s    .gok2             If so, try the B bits.
  86.     bhi.s    .gsub2             If the target has smaller amount of green-----|
  87. .gadd2    add    #%00001000000,d2     Otherwise add an element of green.           |
  88.     bra.s    .gok2                                       |
  89. .gsub2    subi    #%00001000000,d2     ... take away an element of green. <----------|
  90. .gok2
  91. .blue2    move    d1,d3            {
  92.     move    d2,d4            { --- Isolate B bits
  93.     andi    #%11111,d3        {
  94.     andi    #%11111,d4        {
  95.     cmp    d3,d4            Are the B bits the same?
  96.     beq.s    .bok2             If so, finish.
  97.     bhi.s    .bsub2             If the target has smaller amounts of blue-----|
  98. .badd2    addq.l    #1,d2             Otherwise add an element of blue.           |
  99.     bra.s    .bok2                                       |
  100. .bsub2    subq.l    #1,d2             ... take away an element of blue. <-----------|
  101. .bok2    
  102.  
  103.     swap    d2    
  104.     move.l    d2,(a0)+        Put changed pixel on screen.
  105.     rts
  106. .bye    addq.l    #4,a0
  107.     rts
  108.     
  109.